package com.onlinelibrary.activities.main;

import android.annotation.SuppressLint;
import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.BindingAdapter;
import androidx.lifecycle.AndroidViewModel;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.onlinelibrary.R;

public class MainVM extends AndroidViewModel {
    @SuppressLint("StaticFieldLeak")
    private static MainActivity mainActivity;

    public MainVM(@NonNull Application application) {
        super(application);
    }

    public void setBinding(MainActivity mainActivity) {
        MainVM.mainActivity=mainActivity;

    }
    @BindingAdapter("bindNav")
    public static void bindNav(BottomNavigationView navView,MainVM mainVM){
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(R.id.navigation_tour,R.id.navigation_service , R.id.navigation_comment,R.id.navigation_me).build();
        NavController navController = Navigation.findNavController(mainActivity, R.id.nav_host_fragment);
        NavigationUI.setupActionBarWithNavController(mainActivity, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);
    }
}
